Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consecutive key presses #20

Merged
merged 7 commits into from
May 18, 2021
Merged

Conversation

pheerai
Copy link
Contributor

@pheerai pheerai commented May 1, 2021

Feature Proposal:

Allows to pass several key codes that will be executed after one another. To do this, blocks of key codes are separated using /.

To make the key codes more readable in the config, this also introduces white-space trimming, making it possible to give 29-20/46/46/12/30/32/50/23/49/28 as 29-20 / 46 / 46 / 12 / 30 / 32 / 50 / 23 / 49 / 28. A rewrite to using an array would be another option, but will break existing setups.

The delays are configurable, defaulting to 100ms. If not enough delay values are given, the last one is repeated.

I am a bit unsure about the location of the array helpers – they might even be provided by go somewhere, I am not that proficient with it – as well the pad handling. It is possible to reduce the cases here down to "no entry" vs. "some entry", using the padding function in both cases, but this might be less clear.

Any comment on these issues, as well as regarding naming conventions or any other concern, is really appreciated.

As for the motivation: I use this code on my setup, e.g. to interface with the browser. Issue Ctrl+t to open a new tab, wait until it is responsive (~150ms), then type some bookmark alias char by char with less delay between the events (20ms)

Thanks for this tool 👍

@muesli
Copy link
Owner

muesli commented May 14, 2021

Nice, I like this! I do wonder however, if we shouldn't combine key-codes and delays somehow.

Delay is not passed as array, but as part of the keypress using "+<delayMs>"
@pheerai
Copy link
Contributor Author

pheerai commented May 14, 2021

I changed the code to implement your proposal:
The default delay is "immediately" now.
If delay is required, it should get appended after the keycodes like so:
9-20+200 / 46 / 46 / 12 … (resulting in a 200ms delay after the first key and no additional delay for all the others)

@muesli
Copy link
Owner

muesli commented May 17, 2021

@pheerai Thanks, I think I like the syntax! Will review this asap!

@muesli muesli added the enhancement New feature or request label May 18, 2021
@muesli muesli changed the title Consecutive keybindings Consecutive key presses May 18, 2021
@muesli muesli merged commit a85afb6 into muesli:master May 18, 2021
@muesli
Copy link
Owner

muesli commented May 18, 2021

Pushed a few minor cleanups. Thank you for your contribution, @pheerai! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants